Skip to content

i18n: Fix untranslated strings in views and errors#152

Merged
tmorrell merged 2 commits intoinveniosoftware:masterfrom
mesemus:i18n-gettext
Jun 9, 2025
Merged

i18n: Fix untranslated strings in views and errors#152
tmorrell merged 2 commits intoinveniosoftware:masterfrom
mesemus:i18n-gettext

Conversation

@mesemus
Copy link
Contributor

@mesemus mesemus commented Dec 10, 2024

Description

There are untranslated permission and usage errors in views.py and errors.py.
This PR fixes those by using gettext from invenio-i18n.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

There are untranslated permission and usage errors in views.py and errors.py.
This commit fixes those by using `gettext` from invenio-i18n.

Co-authored-by: Miroslav Simek <[email protected]>
Replaced gettext("...{aaa}...").format(aaa=) pattern with gettext("...%(aaa)s...", aaa=)
to be more consistent with lazy_gettext uses.
Comment on lines +75 to +77
self.description = _(
"Unknown statistic '%(query_name)s'", query_name=query_name
)
Copy link
Member

@Samk13 Samk13 Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question: Did you try if this style works with gettext, or should we use the following instead?

Suggested change
self.description = _(
"Unknown statistic '%(query_name)s'", query_name=query_name
)
self.description = _(
"Unknown statistic '%(query_name)s'"
) % { "query_name": query_name }

The same question applies to the rest of the strings with gettext.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've just retried in invenio shell and it works for me:

image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and for non-english:

image

@tmorrell
Copy link
Contributor

tmorrell commented Jun 9, 2025

Tests have been fixes in master and aren't related to translations. CI should work after merging.

@tmorrell tmorrell merged commit ac0437b into inveniosoftware:master Jun 9, 2025
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants